<?php
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 便民信息  项目的 网站 网站消息模块
// Copyright (c) 2015 – 2016 http://www.lijian.website
// 时间:2016年1月21日上午9:31:17
// 用户名:Lenovo
// 作   者:小天天天天
/////////////////////////////////////////////////////////////////////////////
namespace Admin\Controller;
use Think\Controller;
class WebinfoController extends Controller{
	public function index(){
		$webinfomodel=M("Webinfo");
		$webinfo=$webinfomodel->find(1);
		//var_dump($webinfo);
		$this->assign("webinfo",$webinfo);
		
		$this->display();
	}
	
	public function update() {
		$data['id']=1;
		$data['web_name']=$_POST['web_name'];
		$data['web_url']=$_POST['web_url'];
		$data['web_description']=$_POST['web_description'];
		$data['web_keywords']=$_POST['web_keywords'];
		$data['is_varify']=$_POST['is_varify'];
		$data['web_notice']=$_POST['web_notice'];
		$data['web_icp']=$_POST['web_icp'];
		$data['foot_info']=$_POST['foot_info'];
		if (!empty($_FILES['web_logo']["name"])){
			$file=$_FILES['web_logo'];
			$config = array(
					'replace'     =>true,
					'maxSize'    =>512000,
					"rootPath" =>"./Public/",
					'savePath'   =>    'Home/images/',
					'autoSub'=>false,
					'saveName'   =>    "logo",
					'exts'       =>    array( 'png')
			);
			$upload=new \Think\Upload($config);
		
			$info=$upload->uploadOne($file);
			if (!$info){
				$this->error($upload->getError());
			}
		}
		
		$webinfomodel=M("Webinfo");
		foreach ($data as $k=>$v){
			$data[$k]=addslashes($v);
		}
		if ($webinfomodel->save($data)){
			$this->success("网站消息更新成功!");
		}else {
			$this->error("网站消息更新失败!");
		}
		
	}
}